layui.define([ 'form', 'laydate', 'table','greenTreatmentApi'], function(exports) {
    var form = layui.form;
    var greenTreatmentApi = layui.greenTreatmentApi;
    var index = layui.index;
    var view = {
        init:function(){
            Lib.initGenrealForm($("#addForm"),form);
            this.initSubmit();
        },
        initSubmit:function(){
            $("#addButton").click(function(){
                form.on('submit(form)', function(){
                        greenTreatmentApi.addgreenTreatment($('#addForm'), function () {
                            parent.window.dataReload();
                            Common.info("添加成功");
                            Lib.closeFrame();
                        });
                });
            });

            $("#addButton-PandD").click(function(){
                form.on('submit(form)', function(){
                        Common.openConfirm("确认申报?", function () {
                            greenTreatmentApi.savedeclaration($('#addForm'), function () {
                                parent.window.dataReload();
                                Common.info("保存并申报成功");
                                Lib.closeFrame();
                            });
                        }, null);
                });
            });

            $("#addButton-cancel").click(function(){
                Lib.closeFrame();
            });
        }

    }
    exports('add',view);
});